package com.liuxu.topnews;

import android.app.Application;
import android.content.Context;
import android.content.res.AssetManager;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

public class MyApplication extends Application {
    public static Context context;
    public static Toast toast;
    public static boolean permission;
    public static boolean Pause;
    public static boolean sleep;
    public static boolean update;
    public static boolean must;
    public static String updateinfo;
    public static String UpClassName;
    public static String NowClassName;
    public static String appname;
    public static String packname;
    public static String mainname;
    public static String newsname;
    public static Map topics=new HashMap();
    public static AssetManager assetManager;
    public static boolean exit;

    @Override
    public void onCreate() {
        super.onCreate();
        init();
    }
    public void init(){
        toast=Toast.makeText(this,"初始化",Toast.LENGTH_SHORT);
        context = getApplicationContext();
        permission=false;
        Pause=false;
        exit=false;
        assetManager=getAssets();
        topics.put("200","成功");
        topics.put("100","失败");
        topics.put("10","注册码错误");
        topics.put("口令",getResources().getString(R.string.tourl));
        topics.put("注册",getResources().getString(R.string.reurl));
        topics.put("运行",getResources().getString(R.string.idurl));
        topics.put("解绑",getResources().getString(R.string.caurl));
        topics.put("更新",getResources().getString(R.string.upurl));
        Log.v("应用","初始化成功");
    }

    public String getappinfo(String name,int index) throws NoSuchFieldException, IllegalAccessException {
        Field field = AppInfo.class.getDeclaredField(name);
        field.setAccessible(true);
        String[] result=(String[])field.get(new AppInfo());
        return (result[index]);
    }

    public static Context getContext() {
        return context;
    }

    public static Map getTopics(){
        return topics;
    }

    public  void setUpdateinfo(String updateinfo){
        this.updateinfo=updateinfo;
    }

    public  String getUpdateinfo(){
        return updateinfo;
    }

}
